function mhcx() {
    var param={};
    param.lineCode=$("[name=lineCode]").val();
    param.isStart=$("[name=isStart]").val();
    $("#poleTb").bootstrapTable("refresh",{query:param});
}
function queryParams(param){
    param.lineCode=$("[name=lineCode]").val();
    param.isStart=$("[name=isStart]").val();
    return param;
}
function fomStart(value,row) {
    return value==1?"启用":"停用";
}

function addPole(){
    $("#add form")[0].reset();
    $("#add").dialog("open");
}

$(function(){
    $("#add").dialog({
        title:"添加杆塔",
        btnName:"确定",
        btnBind:function(){
            var param=$("#add form").serialize();
            $.post(ctx+"pole/addPole",param,function(msg){
                toastr.warning("信息提示",msg);
                $("#add").dialog("close");
                $("#poleTb").bootstrapTable("refresh");
            },'text');
        }
    });
});
$(function(){
    $.getJSON(ctx+"pole/searchAll",function(arr){
        $(arr).each(function(){
            var $opt=$("<option/>");
            $opt.html(this.poleCode);
            $opt.val(this.poleCode);
            $opt.appendTo("[name=poleCode]");
        });
    });
});

function delPole(){
    var arr = $("#poleTb").bootstrapTable("getSelections");
    if(arr.length==0){
        swal({
            title: "信息提示",
            text: "请选择一项待删除！",
            type: "warning",
            showCancelButton: false,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定"
        });
        return;
    }
    swal({
        title:"确定要删除吗？",
        text:"该操作不可逆，请谨慎操作！",
        type:"warning",
        showCancelButton:true,
        confirmButtonColor:"#DD6B55",
        confirmButtonText:"确定",
        cancelButtonText:"取消",
        closeOnConfirm:false,
        closeOnCancel:false
    }).then(function(){
        var params = $(arr).map(function(){
            return "ids="+this.id;
        }).get().join("&");
        $.post("pole/delPole",params,function(isOk){
            if(isOk=="1")
                toastr.success("删除成功！");
            else
                toastr.error("删除失败！");
            $("#poleTb").bootstrapTable("refresh");
        })
    })
}

